##############################
#
# WELCOME
#
# This is the main cmake configuration file
# associate to your project
# You can define here specific compilation options
#
# More about cmake : www.cmake.org


############################ PROJECT NAME
PROJECT( GENERICVIDEOMODULE )




############################ DEFINITION
# Add here definition needed.
ADD_DEFINITIONS( ${ALCOMMON_DEFINITIONS} ${PTHREAD_DEFINITIONS} ${TINYXML_DEFINITIONS} ${OPENCV_DEFINITIONS}  ${BOOST_DEFINITIONS})




############################ INCLUDE DIRECTORY
# Define include directories
INCLUDE_DIRECTORIES( ${PROXIES_INCLUDE_DIR} ${ALCOMMON_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR}  ${TINYXML_INCLUDE_DIR}  ${OPENCV_INCLUDE_DIR} ${BOOST_INCLUDE_DIR})




############################ PROJECT SOURCES FILES
# Add here source files needed to compile this project
SET(GENERICVIDEOMODULE_SRCS

#<FILES> don't remove this comment
gvmsample.cpp gvmsample.h
#</FILES> don't remove this comment

    genericvideomodule.cpp genericvideomodule.h
  )



############################ CHECK LIBRARY / EXECUTABLE OPTION

IF( GENERICVIDEOMODULE_IS_REMOTE STREQUAL "OFF" )
    MESSAGE( STATUS "genericvideomodule is compiled as dynamic object" )
    ADD_LIBRARY( genericvideomodule SHARED ${GENERICVIDEOMODULE_SRCS} )
ELSE( GENERICVIDEOMODULE_IS_REMOTE STREQUAL "OFF" )
    MESSAGE( STATUS "genericvideomodule is compiled as remote object" )
    ADD_EXECUTABLE( genericvideomodule ${GENERICVIDEOMODULE_SRCS} )
ENDIF( GENERICVIDEOMODULE_IS_REMOTE STREQUAL "OFF" )




############################ SET LIBRARIES TO LINK WITH
TARGET_LINK_LIBRARIES( genericvideomodule ${ALCOMMON_LIBRARIES} ${PTHREAD_LIBRARIES} ${NEWMAT_LIBRARIES}  ${TINYXML_LIBRARIES}  ${OPENCV_LIBRARIES} ${BOOST_LIBRARIES})




############################ BINARY COPY
# copy binaries in the output folder automatically
GET_TARGET_PROPERTY( GENERICVIDEOMODULE_LOCATION genericvideomodule LOCATION)


IF ( WIN32 )
    STRING(REGEX REPLACE "genericvideomodule.dll" "" GENERICVIDEOMODULE_LOCATION_SRC ${GENERICVIDEOMODULE_LOCATION})
    SET (OUTPUT_ROOT_DIR_LIB ${AL_DIR}/modules/lib/ )
    FILE(TO_NATIVE_PATH ${GENERICVIDEOMODULE_LOCATION_SRC} GENERICVIDEOMODULE_LOCATION_SRC)
    FILE(TO_NATIVE_PATH ${OUTPUT_ROOT_DIR_LIB} OUTPUT_ROOT_DIR_LIB)
ENDIF ( WIN32 )


IF( GENERICVIDEOMODULE_IS_REMOTE STREQUAL "OFF" )

IF (WIN32)
	  ADD_CUSTOM_COMMAND(
	    TARGET genericvideomodule
	    POST_BUILD
	    COMMAND echo ${GENERICVIDEOMODULE_LOCATION_SRC}*
    	    COMMAND echo ${OUTPUT_ROOT_DIR_LIB}
	    COMMAND xcopy  ${GENERICVIDEOMODULE_LOCATION_SRC}*.dll ${OUTPUT_ROOT_DIR_LIB} /Y /C
	  )
ELSE (WIN32)

  ADD_CUSTOM_COMMAND(
    TARGET genericvideomodule
    POST_BUILD
    COMMAND ${CMAKE_COMMAND}
    ARGS -E copy
    ${GENERICVIDEOMODULE_LOCATION}
    ${OUTPUT_ROOT_DIR_LIB}
  )
 ENDIF (WIN32)
 ELSE( GENERICVIDEOMODULE_IS_REMOTE STREQUAL "OFF" )
  ADD_CUSTOM_COMMAND(
    TARGET genericvideomodule
    POST_BUILD
    COMMAND ${CMAKE_COMMAND}
    ARGS -E copy
    ${GENERICVIDEOMODULE_LOCATION}
    ${OUTPUT_ROOT_DIR_EXE}
  )
ENDIF( GENERICVIDEOMODULE_IS_REMOTE STREQUAL "OFF" )

